
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$school['title']}</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
<link rel="stylesheet" href="{MODULE_URL}public/mobile/css/weixin.css">
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/mGrzx.css?v=4.8" />
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/pageContent.css?v=4.80120" />
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/greenStyle.css?v=4.80120" />
{php echo register_jssdk();}
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="{OSSURL}public/mobile/js/PromptBoxUtil.js?v=4.80309"></script>
</head>
<body>
<div class="all" style="padding-bottom:55px;">
	<div class="header mainColor">
		<div class="l">
			<a class="backOff" style="background:url({OSSURL}public/mobile/img/ic_arrow_left_48px_white.svg) no-repeat;background-size: 55% 55%;background-position: 50%;" href="javascript:history.go(-1);"></a>
		</div>
		<div class="m">
			<span style="font-size: 18px">绑卡记录</span>   
		</div>
	</div>
	<div id="titlebar_bg" class="_header"></div>	
	<div class="stuBox">
		<div class="stuInfo">
			<div class="parentHeader">
				<img alt="" src="{if !empty($students['icon'])}{php echo toimage($students['icon'])}{else}{php echo toimage($school['spic'])}{/if}" />
			</div>
			<div class="stuInfoCenter">
				<div id="parentName" class="stuName">
					<label class="m_r_10">&nbsp;{$student['s_name']}</label>
				</div>
				<div class="stuCampusAndBjname">
					<span>已绑定{$num}张</span>
				</div>
			</div>
		</div>
		<div class="stuServer">
			<label>考勤</label>
			<div class="server">
				<span>{$checktotal}次</span>
			</div>
			<div class="unbound" onclick="exchange();">记录</div>
		</div>
	</div>
	<div class="parentBox">
		<ul>
		{loop $list $item}
			<li>
				<div class="parentInfo">
					<div class="left">
					  <input type="hidden" id="bigImage" name="bigImage"/>	
					  <div class="stuHeader_new" onclick="uploadImg(this,{$item['id']});">
						<img src="{if !empty($item['spic'])}{php echo tomedia($item['spic'])}{else}{OSSURL}public/mobile/img/boyteacher.jpg{/if}"/>
					  </div>
					  <div class="stuName_new">
						{$item['pname']}
					  </div>
					</div>
					<div class="center">
						<div class="lineInfo">
							<span class="colorInfo green" style="background-color: #14c682;color:#fff;!important">使用者</span>
							<span class="normalInfo">关系:						
							{if $item['pard'] == 1}本人{/if}
							{if $item['pard'] == 2}妈妈{/if}
							{if $item['pard'] == 3}爸爸{/if}
							{if $item['pard'] == 4}爷爷{/if}
							{if $item['pard'] == 5}奶奶{/if}
							{if $item['pard'] == 6}外公{/if}
							{if $item['pard'] == 7}外婆{/if}
							{if $item['pard'] == 8}叔叔{/if}
							{if $item['pard'] == 9}阿姨{/if}
							{if $item['pard'] == 10}其他{/if}
						    </span>
						</div>					
						<div class="lineInfo">
							<span class="colorInfo green" style="background-color: #14c682;color:#fff;!important">已绑定</span>
							<span class="normalInfo">卡号:{$item['idcard']}</span>
						</div>
						<div class="lineInfo">
						{if $school['is_cardpay'] ==1}
							<span class="colorInfo red" style="background-color: {if $item['severend']>TIMESTAMP}#14c682;{else}#fc5b5b;{/if}color:#fff;!important">
								{if $item['severend']>TIMESTAMP}
								服务中
								{else}
								已到期
								{/if}
							</span>
							<span class="normalInfo">{php echo date('Y-m-d', $item['severend'])}到期</span>
						{else}
							<span class="colorInfo red" style="background-color: #14c682;color:#fff;!important">服务中</span>
							<span class="normalInfo">{php echo date('Y-m-d', $item['createtime'])}绑定</span>						
						{/if}	
						</div>
					</div>
					<div class="righta">
						<a onclick="jiebang({$item['id']});">解绑</a>
					</div>
					{if $school['is_cardpay'] == 1}
					<div class="rightb">
						<a onclick="gopay({$item['id']});">续费</a>
					</div>
					{/if}	
				</div>
			 </li>
		{/loop}
		{if !empty($list)}
			<li class="no_padding">
				<span class="l"></span>
				<span class="remind">
					<i><img alt="" src="{OSSURL}public/mobile/img/ico_attention.png" /></i>
					<label>点击家长头像可以修改</label>
				</span>
			</li>
		{/if}	
		</ul>
	</div>
	<div class="payWeixt">
		<a id="bangding">绑定新卡</a>	
	</div>
    <div class="user_info" id="user_info1" style="display:none;">
	   <div>
			<ul>
				<p>绑定考勤卡</p>
				<li class="user_name">
				关系
					<select  id="guanxi">
						<option value="" >选择本卡使用者与学生关系</option>
						<option value="1" >本人</option>
						<option value="2" >妈妈</option>
						<option value="3" >爸爸</option>
						<option value="4" >爷爷</option>
						<option value="5" >奶奶</option>
						<option value="6" >外公</option>
						<option value="7" >外婆</option>
						<option value="8" >叔叔</option>
						<option value="9" >阿姨</option>		
						<option value="10" >其他</option>
					</select>
				   <input type="hidden" name="guanxi" id="guanxi" value="" />			
				</li>
				<li class="user_name">
				  姓名
					<input type="text" placeholder="请输入本卡使用者姓名" name ="username" id="username" value="">  
				</li>				
				<li class="user_name">
				  卡号
					<input type="text" placeholder="请输入您的考勤卡号" name ="munber" id="munber" value="">  
				</li>						
				<div class="btn" id="bdax">提交</div>
			</ul>
			<span id="clos">×</span>
	   </div>
    </div>	
</div>
{php include $this->template('footer');}	
</body>
<script type="text/javascript">
var PB = new PromptBox();

function WeixinJSHideAllNonBaseMenuItem(){
	if (typeof wx != "undefined"){
		wx.ready(function () {
			
			wx.hideAllNonBaseMenuItem();
		});
	}
}
function exchange(){
	location.href = "{php echo $this->createMobileUrl('calendar', array('schoolid' => $schoolid,'userid'=>$it['id']), true)}";
}
function gopay(cardid){
	var submitData = {
				weid:"{$weid}",
				schoolid:"{$schoolid}",
				sid:"{$it['sid']}",
				userid:"{$it['id']}",
				uid:"{$it['uid']}",
				bj_id:"{$student['bj_id']}",
				id:cardid,
				openid:"{$openid}",
	};
	var truthBeTold = window.confirm('确认要续费吗?'); 
	if (truthBeTold) {
		$.post("{php echo $this->createMobileUrl('payajax',array('op'=>'xuefeiidcard'))}",submitData, function(data) {
			if (data.result) {
				location.href = data.msg;
			} else {
				PB.prompt(data.msg);
			}
		},'json');
	}
}
function jiebang(id) {
	var submitData = {
				openid   : "{$openid}",
				id       : id
	};
	var truthBeTold = window.confirm('确认要解绑此卡吗?'); 
	if (truthBeTold) {
		$.post("{php echo $this->createMobileUrl('indexajax',array('op'=>'jbidcard'))}",submitData, function(data) {
			if (data.result) {
				PB.prompt(data.msg);
				location.reload();
			} else {
				PB.prompt(data.msg);
			}
		},'json');
	}
}
</script>
<script type="text/javascript">
	$(function ($) {
		WeixinJSHideAllNonBaseMenuItem();
		//弹出	
		$("#bangding").on('click', function () {
            $('#user_info1').show();
		});
		$("#clos").on('click', function () {
            $('#user_info1').hide();
		});	
		//文本框不允许为空---按钮触发	
		$("#bdax").on('click', function () {
			var pard =  $("#guanxi").val(); 
			var munber = $("#munber").val();
			var username = $("#username").val();
			var truthBeTold = window.confirm('确认要新增本卡吗?'); 
		     data = {
				weid:"{$weid}",
				schoolid:"{$schoolid}",
				sid:"{$it['sid']}",
				userid:"{$it['id']}",
				uid:"{$it['uid']}",
				bj_id:"{$student['bj_id']}",
				idcard:munber,
				pard:pard,
				username:username,
				openid:"{$openid}",
				'json':''
            }
			if (munber == "" || munber == undefined || munber == null) {
            alert('请输入卡号！');
            return false;
			}
			
			if (munber.length !=10 || isNaN(munber)) {
            alert('非法卡号！');
            return false;
			}			
			
			if (pard == "" || pard == undefined || pard == null) {
            alert('请选择本卡使用者与学生关系！');
            return false;
			}
			
			if (truthBeTold) {
				$.post("{php echo $this->createMobileUrl('indexajax',array('op'=>'bangdingcardjl'))}",data,function(data){
                    if(data.result){
					    alert(data.msg);
                        location.reload();
                    }else{
                        alert(data.msg);
                    }
                },'json');	
			} else $('#user_info1').hide();	
		});		
	});
</script>
<script>
var PB = new PromptBox();
var images = {
	    localId: [],
	    serverId: []
};

function uploadImg(node,id){

	wxChooseImage(id);
}

/**
 * 微信选择图片
 */
function wxChooseImage(id){
	wx.chooseImage({
		success: function (res) {
			images.localId = res.localIds;
			var obj=new Image();
			obj.src=res.localIds[0];
			imagesUploadWx(id);
		}
	});
};

function imagesUploadWx(id) {
	      wx.uploadImage({
	        localId: images.localId[0],
	        isShowProgressTips:1,//// 默认为1，显示进度提示
	        success: function (res) {
	        	$("#bigImage").val(res.serverId);
				saveImage(id);
	        },
	        fail: function (res) {
	          alert(JSON.stringify(res));
	        }
	      });
};

function saveImage(id) {
	PB.prompt("家长头像上传中，请稍等~","forever");
	var url = "{php echo $this->createMobileUrl('indexajax',array('op'=>'changePimg'))}";
	var submitData = {
			bigImage:$("#bigImage").val(),
			id:id,
	};
	$.post(url, submitData, function(data) {
		if (data.result) {
			PB.prompt(data.msg);
			location.reload();
		} else {
			PB.prompt(data.msg);
		}
	},'json');
}
</script>
</html>